<%--
  Created by IntelliJ IDEA.
  User: feng
  Date: 2023/5/14
  Time: 9:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>体育馆管理系统</title>
    <meta name="description" content="体育馆管理系统">
    <meta name="keywords" content="体育馆管理系统">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="<%=request.getContextPath()%>/resources/plugins/elementui/index.css">
    <link rel="stylesheet" href=".<%=request.getContextPath()%>/resources/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/resources/css/style.css">
    <!-- 引入组件库 -->
    <script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/jquery.min.js"></script>
    <script src="<%=request.getContextPath()%>/resources/js/vue.js"></script>
    <script src="<%=request.getContextPath()%>/resources/js/axios-0.18.0.js"></script>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/resources/css/page-health-login.css" />
    <link rel="stylesheet" href="<%=request.getContextPath()%>/resources/plugins2/elementui/index.css" />
    <script src="<%=request.getContextPath()%>/resources/plugins2/jquery/dist/jquery.min.js"></script>
    <script src="<%=request.getContextPath()%>/resources/plugins2/healthmobile.js"></script>
    <script src="<%=request.getContextPath()%>/resources/plugins2/vue/vue.js"></script>
    <script src="<%=request.getContextPath()%>/resources/plugins2/vue/axios-0.18.0.js"></script>
    <script src="<%=request.getContextPath()%>/resources/plugins2/elementui/index.js"></script>
    <style>
        .datatable {
            position: relative;
            box-sizing: border-box;
            -webkit-box-flex: 1;
            width: 100%;
            max-width: 100%;
            font-size: 14px;
            color: rgb(96, 98, 102);
            overflow: hidden;
            flex: 1 1 0%;
        }
        .datatable td, .datatable th {
            padding: 12px 0;
            min-width: 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            text-overflow: ellipsis;
            vertical-align: middle;
            position: relative;
            text-align: left;
        }
    </style>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>场地预约<small>场地预约</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>预约管理</el-breadcrumb-item>
            <el-breadcrumb-item>场地预约</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <el-input placeholder="场地号/场地名" v-model="pagination.queryString" style="width: 200px;"
                          class="filter-item" @keyup.enter.native="handleFilter"></el-input>
                <el-date-picker
                        v-model="pagination.orderData"
                        type="date"
                        class="filter-item"
                        format="yyyy 年 MM 月 dd 日"
                        :picker-options="applyPickerOptions"
                ></el-date-picker>
                <el-select placeholder="请选择" v-model="pagination.orderTimeSub"  style="width: 200px;" class="filter-item">
                    <el-option v-for="item in kindList" :key="item.id" :value="item.name"></el-option>
                </el-select>
                <el-button @click="findPage()" class="dalfBut">查询</el-button>

            </div>
            <el-table size="small" current-row-key="placeNo" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="placeNo" label="场地号" align="center"></el-table-column>
                <el-table-column prop="placeName" label="场地名" align="center"></el-table-column>
                <el-table-column prop="orderCost" label="租借费用" align="center"></el-table-column>
                <el-table-column prop="orderData" label="租用日期" align="center"></el-table-column>
                <el-table-column prop="orderTimeSub" label="时间段" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="handleMess(scope.row)">查看详情</el-button>
                        <el-button size="mini" type="danger" @click="handleDelete(scope.row)">退选</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.pageNow"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>

            <!-- 详情标签弹层 -->
            <div class="add-form">
                <el-dialog title="订单详情" :visible.sync="dialogFormVisible4Edit">
                    <template>
                        <el-tabs v-model="activeName" type="card">
                            <el-tab-pane label="场地信息" name="first">
                                <el-form label-position="right" label-width="100px">
                                    <el-row>
                                        <el-col :span="8">
                                            <el-form-item label="场地号">
                                                <el-input v-model="formData.placeNo" :disabled="true"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="8">
                                            <el-form-item label="场地名">
                                                <el-input v-model="formData.placeName" :disabled="true"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="8">
                                            <el-form-item label="场地费用">
                                                <el-input v-model="formData.orderCost"  :disabled="true"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="8">
                                            <el-form-item label="租用用户编号">
                                                <el-input v-model="formData.lesseeID" :disabled="true"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="8">
                                            <el-form-item label="租用日期">
                                                <el-input v-model="formData.orderData" :disabled="true"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="8">
                                            <el-form-item label="租用时间段">
                                                <el-input v-model="formData.orderTimeSub" :disabled="true"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>

                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="备注">
                                                <el-input v-model="formData.orderRemark" type="textarea" :disabled="true"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                        </el-tabs>
                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible4Edit = false">确定</el-button>
                    </div>
                </el-dialog>
            </div>


        </div>
    </div>
</div>
</body>
<script>

    var vue = new Vue({
        el: '#app',
        data(){
            let that = this;
            return {
                activeName:'first',//添加/编辑窗口Tab标签名称
                pagination: {//分页相关属性
                    pageNow: 1,
                    pageSize:10,
                    total:100,
                    queryString:null,
                    orderTimeSub:"08点-10点",
                    orderData:new Date(),
                },
                dataList: [],//列表数据
                formData: {},//表单数据
                tableData:[],//新增和编辑表单中对应的检查项列表数据
                checkitemIds:[],//新增和编辑表单中检查项对应的复选框，基于双向绑定可以进行回显和数据提交
                dialogFormVisible: false,//控制添加窗口显示/隐藏
                dialogFormVisible4Edit:false,//控制编辑窗口显示/隐藏
                dialogFormVisible4EditAdd:false,//控制编辑窗口显示/隐藏
                kindList:[{name:"08点-10点",id:"1"},{name:"10点-12点",id:2},{name:"13点-15点",id:3}
                    ,{name:"15点-17点",id:4},{name:"17点-19点",id:5},{name:"19点-21点",id:6}],
                expireTimeOPtion: {
                    disabledDate(time) {
                        return time.getTime() < Date.now();  //如果没有后面的-8.64e7就是不可以选择今天的
                    }
                },
                selectDate: new Date(), // 记录首次选择的时间
                applyPickerOptions: {
                    disabledDate(time) {
                        let timeOptionRange = that.selectDate;
                        let secondNum = -(60 * 60 * 24  * 1000 * 2); // 时间跨度为7天【一年以365天的时间计算】的限制
                        let secondNum2 = 60 * 60 * 24  * 1000; // 时间跨度为7天【一年以365天的时间计算】的限制
                        if (timeOptionRange) {
                            return time.getTime() > timeOptionRange - secondNum || time.getTime() < timeOptionRange-secondNum2;
                        }
                    }
                }
            }

        },
        created() {
            this.findPage();
        },
        methods: {
            //分页查询
            findPage() {
                //分页参数
                var param = {
                    pageNow:this.pagination.pageNow,//页码
                    pageSize:this.pagination.pageSize,//每页显示的记录数
                    placeNo:this.pagination.queryString,//场地号
                    placeName:this.pagination.queryString,//场地号
                    orderData:this.pagination.orderData.getFullYear()+"-"+(this.pagination.orderData.getMonth()+1)+"-"+
                        this.pagination.orderData.getDate(),//租用日期
                    orderTimeSub:this.pagination.orderTimeSub//租用时间段
                    //queryString:this.pagination.queryString//查询条件
                };
                //请求后台
                axios.post("<%=request.getContextPath()%>/denueHireMessage/find.do",param).then((response)=> {
                    //为模型数据赋值，基于VUE的双向绑定展示到页面
                    this.dataList = response.data.data.rows;
                    this.pagination.total =  response.data.data["totalCount"];

                });
            },
            //预约界面
            handleAppAdd(row){
                var param = {
                    placeNo:row["placeNo"],//查询条件
                    orderTimeSub:row["orderTimeSub"],
                    orderData:row["orderData"]
                };

                axios.post("<%=request.getContextPath()%>/denueHireMessage/find.do",param).then((res)=>{
                    console.log("res = " + res.data.data.rows);
                    if(res.data.data.rows.length === 1){
                        //弹出编辑窗口
                        this.dialogFormVisible4EditAdd = true;
                        //为模型数据赋值，通过VUE数据双向绑定进行信息的回显
                        this.formData={};
                        console.log(res.data.data.rows[0]);
                        this.formData = res.data.data.rows[0];
                    }else{
                        this.$message.error("获取数据失败，请刷新当前页面");
                    }
                });
            },
            handleDelete (row) {
                this.$confirm('是否推选该场地?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var param = {
                        orderNo:row["orderNo"],
                    };

                    axios.post("<%=request.getContextPath()%>/denueHireMessage/delete.do",param).then((res)=>{
                       console.log(res);
                        if(res.data.success){
                            this.$message({
                                message: res.data.data,
                                type: 'success'
                            });
                        }else{
                            this.$message.error("获取数据信息失败，请刷新当前页面");
                        }
                    }).finally(()=> {
                        this.findPage();
                    });
                }).catch(() => {
                    // 点击取消进行的操作
                })


            },
            // 重置表单
            resetForm() {
                this.formData = {};
            },
            // 弹出详情窗口
            handleMess(row) {
                var param = {
                    orderNo:row["orderNo"],//查询条件
                };
                axios.post("<%=request.getContextPath()%>/denueHireMessage/find.do",param).then((res)=>{
                    console.log("res = " + res.data.data.rows);
                    if(res.data.data.rows.length === 1){
                        //弹出编辑窗口
                        this.dialogFormVisible4Edit = true;
                        //为模型数据赋值，通过VUE数据双向绑定进行信息的回显
                        this.formData={};
                        console.log(res.data.data.rows[0]);
                        this.formData = res.data.data.rows[0];
                    }else{
                        this.$message.error("获取数据失败，请刷新当前页面");
                    }
                });
            },
            //切换页码
            handleCurrentChange(pageNow) {
                //pageNow为切换后的页码
                this.pagination.pageNow = pageNow;
                this.findPage();
            },
        },

    })
</script>
</html>